﻿using MediatR;
using SheepStorage.API.Application.Command.SheepManagementCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepManagementHandler
{
    public class SheepManagementDelCommandHandler : IRequestHandler<SheepManagementDelCommand, Results<int>>
    {
        private readonly ISheepManagementService sheepManagementService;

        public SheepManagementDelCommandHandler(ISheepManagementService sheepManagementService)
        {
            this.sheepManagementService = sheepManagementService;
        }

        /// <summary>
        /// 羊场删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<int>> Handle(SheepManagementDelCommand request, CancellationToken cancellationToken)
        {
            var list = sheepManagementService.DelSheepManagement(request.SheepManagementId);
            return Results<int>.DataResult(list);
        }
    }
}
